const menuData = [{
  name: '广告主管理',
  icon: 'team',
  path: 'advertiser',
  children: [{
    name: '信息管理',
    path: 'list',
  }],
}, {
  name: '广告投放',
  icon: 'rocket',
  path: 'release',
  children: [{
    name: '订单管理',
    path: 'order',
  }, {
    name: '广告管理',
    path: 'advertising',
  }, {
    name: '效果渠道',
    path: 'aidTask',
  }],
}, {
  name: '数据报表',
  icon: 'pie-chart',
  path: 'report',
  children: [{
    name: '广告数据报表',
    path: 'ad',
  }, {
    name: '订单数据报表',
    path: 'aidTask',
  }],
}];

function formatter(data, parentPath = '', parentAuthority) {
  return data.map((item) => {
    const result = {
      ...item,
      path: `${parentPath}${item.path}`,
      authority: item.authority || parentAuthority,
    };
    if (item.children) {
      result.children = formatter(item.children, `${parentPath}${item.path}/`, item.authority);
    }
    return result;
  });
}

export const getMenuData = () => formatter(menuData);
